package com.jkc.xh.views.headview;

import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.jkc.xh.R;
import com.jkc.xh.network.models.AssetInfoResponse;

import org.androidannotations.annotations.EViewGroup;
import org.androidannotations.annotations.ViewById;

/**
 * Created by wangjie28 on 2015/11/13.
 */
@EViewGroup(R.layout.layout_head_my_money)
public class HeadMyMoney extends RelativeLayout {
    @ViewById(R.id.dta_money_text)
    TextView dta_money_text;
    @ViewById(R.id.enable_money_text)
    TextView enable_money_text;
    @ViewById(R.id.freeze_money_text)
    TextView freeze_money_text;
    @ViewById(R.id.stock_enable_money_text)
    TextView stock_enable_money_text;
    @ViewById(R.id.market_value_text)
    TextView market_value_text;
    @ViewById(R.id.profit_money_text)
    TextView profit_money_text;
    @ViewById(R.id.delay_money_sum_text)
    TextView delay_money_sum_text;
    @ViewById(R.id.delay_money_text)
    TextView delay_money_text;
    @ViewById
    ImageView lamp;


    public HeadMyMoney(Context context) {
        this(context, null);
    }

    public HeadMyMoney(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public void loadInfo(AssetInfoResponse assetInfoResponse) {
        if (assetInfoResponse != null) {
            dta_money_text.setText(assetInfoResponse.dta_money + "");
            freeze_money_text.setText(assetInfoResponse.freeze_money + "");
            profit_money_text.setText(assetInfoResponse.profit_money + "");
            market_value_text.setText(assetInfoResponse.market_value + "");
            stock_enable_money_text.setText(assetInfoResponse.stock_enable_money + "");
            enable_money_text.setText(assetInfoResponse.enable_money + "");
            delay_money_sum_text.setText(assetInfoResponse.delay_money_sum + "");
            if(!TextUtils.isEmpty(assetInfoResponse.delay_money_text)){
                delay_money_text.setText(assetInfoResponse.delay_money_text);
                delay_money_text.setVisibility(View.VISIBLE);
            }else{
                delay_money_text.setVisibility(View.GONE);
            }
            if (assetInfoResponse.isEnoughMoney()) {
                lamp.setImageResource(R.drawable.lamp_ok);
            } else {
                lamp.setImageResource(R.drawable.lamp_no);
            }
            if (assetInfoResponse.isProfit()) {
                profit_money_text.setTextColor(getResources().getColor(R.color.text_color_red));
            } else {
                profit_money_text.setTextColor(getResources().getColor(R.color.text_color_green));
            }

        }
    }


}
